/*
 * @Author: zehao.chen
 * @Date: 2022-07-10 11:03:30
 * @LastEditors: zehao.chen
 * @LastEditTime: 2022-11-21 21:24:00
 * @FilePath: /meeting-admin/src/api/meeting.js
 * @Description:
 *
 */
import http from '@/utils/request'
import {target} from "@/utils/config";

// ================  查询 ==========================

const token = localStorage.getItem(`token-${target}`)
console.log(token)

/**
 * @description: 获取当前模板数据
 * @return {*}
 */
export const getTemplateInfo = (data, config) => {
  return http.get('/pc/arrange/template/getTemplateInfo', { params: data }, config)
}
// ================  查询 ==========================





// ================  新增 ==========================


/**
 * @description: 添加座位区域
 * @return {*}
 */
export const addArea = (data, config) => {
  return http.post('/pc/meetingArea/addArea', data, config)
}


/**
 * @description: 新增座位子区域
 * @return {*}
 */
export const addAreaSub = (data, config) => {
  return http.post(`/pc/meetingAreaSub/addAreaSub`, data, config)
}
// ================  新增 ==========================






// ================  修改 ==========================
/**
 * @description: 修改座位模板
 * @return {*}
 */
export const updateTemplate = (data) => {
  return http.put('/pc/templateLib/updateTemplate', data)
}

/**
 * @description: 修改座位区域
 * @return {*}
 */
export const udpateArea = (data, config) => {
  return http.put('/pc/meetingArea/udpateArea', data, config)
}

/**
 * @description: 修改座位子区域
 * @return {*}
 */
export const updateAreaSub = (data, config) => {
  return http.put('/pc/meetingAreaSub/updateAreaSub', data, config)
}


// ================  修改 ==========================
/**
 * @description: 删除座位子区域
 * @return {*}
 */
export const updateDelFlagBySubIds = (subIds, config) => {
  return http.post(`/pc/meetingAreaSub/updateDelFlagBySubIds?subIds=${subIds}`, {}, config)
}
/**
 * @description: 删除座位区域
 * @return {*}
 */
export const updateDelFlagByAreaIds = (areaIds, config) => {
  return http.post(`/pc/meetingArea/updateDelFlagByAreaIds?areaIds=${areaIds}`, {}, config)
}
// ================  删除 ==========================

/**
 * @description: 应用模板
 * @param {*} data
 * @param {*} config
 * @return {*}
 */
export const useTemplate = (data, config) => {
  return http.put('/pc/templateLib/useTemplate', data, config)

}

/**
 * @description: 发布模板
 * @return {*}
 */
export const publishTemplate = (id, type) => {
  return http.put(`/pc/arrange/template/publishTemplate?id=${id}&type=${type}`)
}

/**
 * @description: 保存排座规则
 * @return {*}
 */
export const saveArrangeRule = (meetingId, arrangeSeatType, isAntiepidemicSeat) => {
  return http.put(`/pc/arrange/template/saveArrangeRule/${meetingId}?arrangeSeatType=${arrangeSeatType}&isAntiepidemicSeat=${isAntiepidemicSeat}`)
}


/**
 * @description: 查询会议议程
 * @return {*}
 */
export const meetingAgenderList = (meetingId) => {
  return http.get(`/pc/meetingAgender/meetingAgenderList/${meetingId}`)
}

/**
 * @description: 更新会议议程
 * @return {*}
 */
export const updateAgender = (data) => {
  return http.post(`/pc/meetingAgender/updateAgender`, data)
}

/**
 * @description: 自定义按钮
 * @return {*}
 */
export const meetingCustomButton = (meetingId) => {
  return http.get(`/pc/meetingCustomButton/${meetingId}`)
}

/**
 * @description: 保存自定义按钮
 * @return {*}
 */
export const updateMeetingCustomButton = (data) => {
  return http.post(`/pc/meetingCustomButton/update`, data)
}

/**
 * @description: 查询会议邀请
 * @return {*}
 */
export const meetingInviteSet = (meetingId) => {
  return http.get(`/pc/meetingInviteSet/${meetingId}`)
}

/**
 * @description: 保存会议邀请
 * @return {*}
 */
export const updateMeetingInviteSet = (data) => {
  return http.post(`/pc/meetingInviteSet/update`, data)
}

/**
 * @description: 会议发布
 * @return {*}
 */
export const publish = (meetingId) => {
  return http.get(`/pc/meetingInfo/publish/${meetingId}`)
}

/**
 * @description: 人员导入
 * @return {*}
 */
export const importPeopleList = (meetingId, data) => {
  return http({
    method: 'POST',
    url: `/pc/arrange/template/importPeopleList?meetingId=${meetingId}`,
    data: data,
    headers: {
      Authorization: token
    }
  })
}

/**
 * @description: 人员导出
 * @return {*}
 */
export const exportPeopleList = (meetingId) => {
  return http({
    method: 'POST',
    url: `/pc/arrange/template/exportPeopleList/${meetingId}`,
    responseType: 'arraybuffer',
  })
}

/**
 * @description: 人员座位导出
 * @return {*}
 */
export const exportSeats = (meetingId) => {
  return http({
    method: 'POST',
    url: `/pc/arrange/template/exportSeats?meetingId=${meetingId}`,
    responseType: 'arraybuffer',
  })
}

/**
 * @description: 重新排座
 * @return {*}
 */
export const refreshArrange = (meetingId) => {
  return http.put(`/pc/arrange/template/refreshArrange/${meetingId}`)
}

/**
 * @description: 根据条件查询座位区域列表
 * @param {*} templateId
 * @return {*}
 */
export const queryAreaByCondition = (templateId) => {
  return http.get(`/pc/meetingArea/queryAreaByCondition?templateId=${templateId}`)
}


/**
 * @description: 保存排座
 * @return {*}
 */
export const savePeopleArrangeInfo = (data,meetingId) => {
  return http({
    method: 'POST',
    url: `/pc/arrange/template/savePeopleArrangeInfo/${meetingId}`,
    data: data
  })
}

/**
 * @description: 查询排座
 * @param {*} data
 * @return {*}
 */
export const searchSeatInfo = (meetingId = '', nameOrPhone = '') => {
  return http({
    method: 'GET',
    url: `/pc/meetingConference/searchSeatInfo?meetingId=${meetingId}&nameOrPhone=${nameOrPhone}`,
  })
}

export const meetingPeople = (data) => {
  return http({
    method: 'POST',
    url: `/pc/meetingPeople/list`,
    data: data
  })
}

export const changeAreaForPeople = (data) => {
  return http({
    method: 'POST',
    url: `/pc/arrange/template/changeAreaForPeople?areaId=${data.areaId}&meetingId=${data.meetingId}`,
  })
}

export const messagePost = (id) => {
  return http({
    method: 'POST',
    url: `/pc/meetingPeople/message?meetingId=${id}`,
  })
}

export const iconList = (data) => {
  return http({
    method: 'GET',
    url: `/pc/meetingIcon/iconList`,
    params: data
  })
}

export const queryIconGroupByCondition = (data) => {
  return http({
    method: 'GET',
    url: `/pc/iconGroup/queryIconGroupByCondition`,
    params: data
  })
}


export const editMettingName = (data) => {
  return http({
    method: 'POST',
    url: `/pc/meetingInfo/editMettingName`,
    data:data
  })
}





